<%@ page import="java.util.*" language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>标签管理系统 - 首页</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <!-- basic styles -->
    <link href="${basePath}/ACE/css/bootstrap.min.css" rel="stylesheet" />
    <link rel="stylesheet" href="${basePath}/ACE/css/font-awesome.min.css" />
    <!--[if IE 7]>
		  <link rel="stylesheet" href="${basePath}/ACE/css/font-awesome-ie7.min.css" />
		<![endif]-->
    <!-- page specific plugin styles -->
    <!-- fonts -->
    <!-- ace styles -->
    <link rel="stylesheet" href="${basePath}/ACE/css/ace.min.css" />
    <link rel="stylesheet" href="${basePath}/ACE/css/ace-rtl.min.css" />
    <link rel="stylesheet" href="${basePath}/ACE/css/ace-skins.min.css" />
    <!--[if lte IE 8]>
		  <link rel="stylesheet" href="${basePath}/ACE/css/ace-ie.min.css" />
		<![endif]-->
    <!-- inline styles related to this page -->
    <!-- ace settings handler -->
    <script src="${basePath}/ACE/js/ace-extra.min.js"></script>
    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
		<script src="${basePath}/ACE/js/html5shiv.js"></script>
		<script src="${basePath}/ACE/js/respond.min.js"></script>
		<![endif]-->
</head>
<body>
    <div class="main-container" id="main-container">
        <div class="main-container-inner">
            <div class="breadcrumbs" id="breadcrumbs">
                <ul class="breadcrumb">
                    <li><i class="icon-home home-icon"></i><a href="welcome.htm" >首页</a> </li>
                    <li><a href="#">图书管理</a> </li>
                    <li class="active">图书列表</li>
                </ul>
                <!-- .breadcrumb -->
            </div>
            <div class="page-content">
                <div class="row">
                    <div class="col-xs-12">
                        <!-- PAGE CONTENT BEGINS -->
                        <div class="col-xs-12">
                            <!-- PAGE CONTENT BEGINS -->
                            <form method="post" action="">
                            <div>
                                <input type="text" placeholder="图书名称" name="bname" value="${param.bname }" class="width-10" />
                                <input type="text" placeholder="图书作者" name="author" value="${param.author }" class="width-10" />								
                                <select class="width-20" name="cid">
                                    <option value="-1">请选择</option>
                                    <c:forEach items="${ca }" var="c">                                   
                                         <option value="${c.cid }"  <c:if test="${c.cid==param.cid }">selected</c:if>>${c.cname }</option>
                                    </c:forEach>
                                </select>
                                <input type="radio" name="status"  value="0" <c:if test="${param.status==0 }">checked</c:if> />借出
                                <input type="radio" name="status"  value="1" <c:if test="${param.status==1 }">checked</c:if> />未借出
                                <input type="hidden" name="pageIndex" value="${page.pageIndex }" />
                                <input type="submit" value="检索" class="btn btn-primary btn-sm" />
                            </div>
                            </form>
                            <div class="hr-12"></div>
                            <div>
                                <table class="table table-hover table-bordered">
                                	<a href="" class="btn" id="deleteAll">批量删除</a>
                                	<a href="${basePath }/book/exportExcel.do" class="btn">导出Excel</a>
                                    <thead>
                                        <tr>
                                        	<th><input type="checkbox" id="selectAll" />序号</th>
                                            <th>图书名称</th>
                                            <th>图书类型</th>
                                            <th>图书作者</th>
                                            <th>出版社</th>
                                            <th>出版时间</th>
                                            <th>图书状态</th>
                                            <th>操作列</th>
                                        </tr>
                                    </thead>
                                    <tbody>
                                    <c:forEach items="${page.data }" var="book" varStatus="status"> 
                                        <tr>
                                        	<td><input type="checkbox" name="bid" value="${book.bid }" />${status.count+(page.pageIndex-1)*page.pageSize }</td>
                                            <td><a href="#">${book.bname }</a></td>
                                            <td>${book.cname }</td>
                                            <td>${book.author }</td>
                                            <td>${book.publisher }                </td>
                                            <td>${book.publishTime }           </td>
                                            <td>${book.state==0?"已经借出":"可以借出" } </td>
                                            <td>
                                                <a href="${basePath }/book/update.do?id=${book.bid}"><i class="icon-edit"></i>修</a>&nbsp;&nbsp;
                                                <a href="${basePath }/book/delete.do?id=${book.bid}"><i class="icon-remove"></i>删</a>&nbsp;&nbsp;
                                                <a href="${basePath }/book/borrow.do?id=${book.bid}"><i class="icon-edit"></i>借阅</a>&nbsp;&nbsp;
                                                <a href="details.htm" target="_blank"><i class="icon-info"></i>详</a>
                                            </td>
                                        </tr>
                                        </c:forEach>                                        
                                    </tbody>
                                </table>
                                <div class="page">
                                	<a href="" class="btn" data="1">首页</a>
                                	<a href="" class="btn" data="${page.pageIndex-1<1?1:page.pageIndex-1 }">上一页</a>
                                	<a href="" class="btn" data="${page.pageIndex+1>page.totalPage?page.totalPage:page.pageIndex+1}">下一页</a>
                                	<a href="" class="btn" data="${page.totalPage }">尾页</a>
                                </div>
                            </div>
                            <!-- PAGE CONTENT ENDS -->
                        </div>
                        <!-- /.col -->
                    </div>
                    <!-- /.row -->
                </div>
                <!-- /.page-content -->
            </div>
            <!-- /.main-container-inner -->
            <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse"><i class="icon-double-angle-up icon-only bigger-110">
            </i></a>
        </div>
        <!-- /.main-container -->
        <script src='${basePath}/ACE/js/jquery-2.0.3.min.js' type="text/javascript"></script>
        <script type="text/javascript">
            if ("ontouchend" in document) document.write("<script src='${basePath}/ACE/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
        </script>
        <script src="${basePath}/ACE/js/bootstrap.min.js" type="text/javascript"></script>
        <script src="${basePath}/ACE/js/typeahead-bs2.min.js" type="text/javascript"></script>
        <script src="${basePath}/ACE/js/ace-elements.min.js" type="text/javascript"></script>
        <script src="${basePath}/ACE/js/ace.min.js" type="text/javascript"></script>
        <script type="text/javascript">
        $(function(){
     	   $(".page>a").click(function(event){
     		   event.preventDefault();        		   
     		   var page=$(this).attr("data");        		   
     		   $("input[name='pageIndex']").val(page);
     		   $("form").submit();        		   
     	   });
     	   
     	   //提交表单 
     	   $("input:submit").click(function(event){
     		   event.preventDefault();  
     		   $("input[name='pageIndex']").val(1);
     		   $("form").submit();           		   
     	   });
     	   
     	   //全选 以及 全不选的效果实现 
     	   $("#selectAll").click(function(){
     		   if(this.checked){     			   
     			   $("tbody input:checkbox").prop("checked",true);
     		   }else{
     			  $("tbody input:checkbox").prop("checked",false);     			   
     		   }     		   
     	   });
     	   
     	   //批量删除图书的信息 
     	   $("#deleteAll").click(function(event){
     		   event.preventDefault();
     		   
     		   var  ids=[];
     		   //遍历 获取需要删除 图书的列表信息  
     		   $("tbody input:checked").each(function(index,item){
     			   ids.push(item.value);     			   
     		   });
     		   ids=ids.join(",");
     		   location.href="${basePath}/book/deleteAll.do?ids="+ids;
     		   
     	   });
     	   
     	   
     	   
     	   
        });
        </script>
</body>
</html>
